<template>
  <div>

    <div class="list-btn">
      姓名:<Input v-model.trim="params.realname" placeholder="请输入姓名" style="width: 200px" clearable @keyup.enter.native="getList(url)" />
    </div>
    <div class="list-btn">
      手机号:<Input v-model.trim="params.phone" placeholder="请输入手机号" style="width: 200px" clearable @keyup.enter.native="getList(url)" />
    </div>
    <div class="list-btn">
      渠道:
      <Select style="width:200px"  v-model="params.channelCode" >
        <!--<Option value=''>全部</Option>-->
        <Option v-for="(item,index) in channelCodeList" :value="item.channelCode"  :key="index">{{ item.channelName }}</Option>
      </Select>
    </div>
    <div class="list-btn">
      认证状态:
      <Select clearable style="width:200px"  v-model="params.type"  placeholder="全部">
        <Option :value=0>全部</Option>
        <Option :value=1>身份证认证</Option>
        <Option :value=2>绑定银行卡</Option>
        <Option :value=3>基础信息认证</Option>
        <Option :value=4>运营商认证</Option>
        <Option :value=5>芝麻分认证</Option>
      </Select>
    </div>
    <div class="list-btn">
      注册时间:<DatePicker type="date" @on-change="startTime"  placeholder="选择时间" style="width: 200px"></DatePicker>
      ～<DatePicker type="date" @on-change="endTime"  placeholder="选择时间" style="width: 200px" ></DatePicker>
    </div>
    <div class="list-btn">
      <Button type="primary" @click="getList(url,'refresh')">搜索</Button>
    </div>
    <page-list :listTitle="listTitle" :list="list" :loading="loading" @selectItem="ids = $event;"></page-list>
    <page-button :current="params.pageCurrent"  :total="total" @changePageNum="params.pageCurrent = $event; getList(url)" @changePageSize="params.pageLimit = $event; getList(url)"></page-button>
     <!-- <input type="file" id="file" style="width:200px" @change="getImg()"/> -->
     <!-- <Button type="primary" @click="upload">上传</Button> -->
  </div>
</template>

<script>
  import listMixin from '../../mixin/list'
  import pageList from '../../template/listTemplate'
  import pageButton from '../../template/pageBtnTemplate'
  import confirmDialog from '../../template/confirmDialogTemplate'

  export default {
    mixins:[listMixin],
    components: {
      pageList,
      pageButton,
      confirmDialog
    },
    data () {
      return {
        tag: {
          'title': '客户列表',
          'path': '/work/user/userList'
        },
       listTitle: [
        {
          title: "注册时间",
          key: "createTime",
          align: "center",
          minWidth:160,
          render: (h, params) => {
             let time = this.getLocalTime(params.row.createTime)
             return h("div", time)
          }
        },
        {
          title: "来源渠道",
          key: "channelName",
          align: "center",
          minWidth:120,
          render:(h,params) => {
            return h('div', params.row.channelName ? params.row.channelName : "—")
          }
        },
        {
          title: "手机号",
          key: "phone",
          align: "center",
          minWidth:120,
          render: (h, params) => {
            let phone = params.row.phone;
            return h('div', `${phone.substr(0,3)}****${phone.substr(7)}`)
          }
        },
        {
          title: "姓名",
          key: "realname",
          minWidth:80,
          align: "center",
           render:(h,params) => {
            return h('div', params.row.realname ? params.row.realname : "—")
          }
        },

        {
          title: "身份证号",
          key: "idc",
          align: "center",
          minWidth:200,
           render:(h,params) => {
            return h('div', params.row.idc ? params.row.idc : "—")
          }
        },
        {
          title: "是否绑定银行卡",
          key: "bankNum",
          align: "center",
          minWidth:180,
          render:(h,params) => {
            return h('div', params.row.bankNum ? '是' : "否")
          }
        },
        {
          title: "基础信息认证",
          key: "basiceApprove",
          align: "center",
          minWidth:120,
          render:(h,params) => {
            return h('div', params.row.basiceApprove == 1 ? '已认证' : "未认证")
          }
        },
         {
           title: "运营商认证",
           key: "carrierApprove",
           align: "center",
           minWidth:120,
           render:(h,params) => {
             return h('div', params.row.carrierApprove ==1 ? '已认证' : "未认证")
           }
         },
           {
            title: "芝麻分",
            key: "zmfScore",
            align: "center",
            minWidth:80,
            render:(h,params) => {
              return h('div', params.row.zmfScore >0 ? params.row.zmfScore : "—")
            }
          },

        {
          title: "操作",
          key: "action",
          minWidth: 150,
          align: "center",
          render: (h, params) => {
            return h("div", [
              h(
                "Button",
                {
                  props: {
                    type: "primary",
                    size: "small"
                  },
                  style: {
                    marginRight: "5px"
                  },
                  on: {
                    click: () => {
                      this.$router.push({path:'/work/user/userEdit',query:{id:params.row.id}})
                      // console.log(params.index);
                      // this.show(params.index);
                    }
                  }
                },
                "查看详情"
              ),
            ]);
          }
        }
      ],
        url:'user/list',
        nameListUrl: '',
        params: {
          pageCurrent: 1,
          pageLimit: 10
        },
      }
    },
    created(){
      this.getChannel();
    },
    methods: {
      getName(selectItem){
        console.log(selectItem);
      }
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
  .list-btn{
    margin-bottom: 5px;
    margin-right: 5px;
    display: inline-block;
  }
  .refresh-btn{
    float: right;
  }
</style>
